﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SharpMUD.Framework.Services;
using SharpMUD.Framework.Services.Security;
using SharpMUD.Framework.Security;

namespace SharpMUD.Framework.Workflow.SessionState
{
    public class RuntimeSessionState<T>
        : ISessionState<T>
        where T : IUserSession
    {
        public RuntimeSessionState(SessionAction<T> action)
        {
            if (action == null) throw new ArgumentNullException("action");

            this.ID = String.Empty;
            this.Action = action;
        }
        public RuntimeSessionState(string id, SessionAction<T> action)
        {
            if (string.IsNullOrEmpty(id)) throw new ArgumentNullException("id");
            if (action == null) throw new ArgumentNullException("action");

            this.ID = id;
            this.Action = action;
        }

        #region ISessionState<T> Members

        public string ID
        { get; private set; }

        public SessionAction<T> Action
        { get; private set; }

        public SessionActionResult PerformAction(T session)
        {
            return this.Action(session);
        }

        #endregion
    }
}
